﻿using DWH.PP;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using DWH.Utils;
using DWH.PP.LoopUrls;

namespace RDTest
{
    
    
    /// <summary>
    ///This is a test class for PPLoopUrlsBoardPullTaskTest and is intended
    ///to contain all PPLoopUrlsBoardPullTaskTest Unit Tests
    ///</summary>
    [TestClass()]
    public class PPLoopUrlsBoardPullTaskTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for Run
        ///</summary>
        [TestMethod()]
        public void AICHTest()
        {
            PPLoopUrlsBoardPullTask target = new PPLoopUrlsBoardPullTask();

            target.Enable = true;
            Guid newId = Guid.NewGuid();
            target.TaskName = "UT for PPLoopUrlsBoardPullTask" + newId.ToString();

            target.ExtendData = new Dictionary<string, string>();
            target.ExtendData[DWHConstants.KEY_CONTENT_PAGE_URL_PATTERN] = @"htm_data/14/\d+/\d+\.html";
            
            target.ExtendData[DWHConstants.KEY_LOOP_PAGELIST_URL_PATTERN] = "http://70.85.48.252/bt/thread.php?fid=14&search=&page={0}";            
            target.ExtendData[DWHConstants.KEY_LOOP_PAGELIST_NUMBER_START] = "1";
            target.ExtendData[DWHConstants.KEY_LOOP_PAGELIST_NUMBER_END] = "10";
            
            target.ExtendData[DWHConstants.KEY_PAGE_ENCODING] = "gb2312";//gb2312
            target.ExtendData[DWHConstants.KEY_CONTENT_TARGET_ELEMENT] = "//table[@style]";//<div id="message12194466" class="t_msgfont">
            target.ExtendData[DWHConstants.KEY_CONTENT_TARGET_ELEMENT_ATTRIBUTE_NAME] = "style";
            target.ExtendData[DWHConstants.KEY_CONTENT_TARGET_ELEMENT_ATTRIBUTE_VALUE] = @"TABLE-LAYOUT: fixed;WORD-WRAP: break-word";

            target.Initialize();
            target.Run();            
        }
    }
}
